package com.example.tbag.healthcare.Util;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;


public class DatabaseHelper extends SQLiteOpenHelper {

    //数据库名字  
    private static final String DB_NAME = "health.db";
    //本版号  
    private static final int VERSION = 1;

    //创建表  
    private static final String CREATE_TABLE_PEOPLE = "CREATE TABLE people(id integer primary key autoincrement," +
            "name text, sex text, age text, type text,bedNum text,doc text,givenMoney text,usedMoney text,leftMoney text)";
    private static final String CREATE_TABLE_DRAG = "CREATE TABLE drag(_id integer primary key autoincrement,id integer" +
                "time text,cure text, drag text, count text,price text,done text)";
    private static final String CREATE_TABLE_HUMANINFO = "CREATE TABLE human(_id integer primary key autoincrement,id integer" +
            "time text, date text, temper text, pulse text,breath text,blood text,sugar text,eg text)";
    private static final String CREATE_TABLE_DOCINFO = "CREATE TABLE doc(" +
            "user text, password text, name text, type text)";
    private static final String CREATE_TABLE_MEDINFO = "CREATE TABLE med(_id integer primary key autoincrement," +
            "name text, money text)";
    //删除表  
    private static final String DROP_TABLE_NOTE = "drop table if exists note";


    public DatabaseHelper(Context context) {
        super(context, DB_NAME, null, VERSION);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        //SQLiteDatabase 用于操作数据库的工具类  
        db.execSQL(CREATE_TABLE_PEOPLE);
        db.execSQL(CREATE_TABLE_DRAG);
        db.execSQL(CREATE_TABLE_HUMANINFO);
        db.execSQL(CREATE_TABLE_DOCINFO);
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        db.execSQL(DROP_TABLE_NOTE);
    }
} 